﻿@model IList<HZU.ZP.Domain.Model.Company>
@{
    Layout = "_AdminLayout";
}
<script type="text/javascript">
    $(document).ready(function () {
        $(".eee").mouseover(function () {
            $(this).css({ "background-color": "gainsboro" });
        }).mouseout(function () {
            $(this).css({ "background-color": "" });
        });
    });
</script>
<script>
    var companyId, companyStatus;
    $(function () {
            $(".nav.nav-tabs li").eq(@((int)ViewData["Status"])).addClass("active");
        });
    $(function () {
        $('#myModal').modal('hide')
    });
    $(function () {
        $('#myModal').on('hide.bs.modal', function () {
            $("#remark").val("");
    })
    });
    function update(id, status)
    {
        companyId = id;
        companyStatus = status;
    }
    function save()
    {
        $.ajax({
                    type: "post",
            url: "/Company/UpdateCompany",
            data: "id=" + companyId + "&status=" + companyStatus + "&remark=" + $("#remark").val(),
                    success: function (message) {
                        if (message.returnCode == "001") {
                            alert("处理成功！")
                            location.reload();
    }
    else if (message.returnCode == "999")
        alert("处理失败！该企业不存在或已处理，请刷新！");
}
});
    }
</script>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    ×
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    审核理由：
                </h4>
            </div>
            <div class="modal-body">
                <input type="text" style="width:100%;" id="remark">
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">
                    关闭
                </button>
                <button type="button" class="btn btn-primary" id="save" onclick="save()">
                    保存
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<div class="container">
    <div class="row clearfix">
        <ul class="nav nav-tabs">
            <li>
                <a href="/Company/CompanyList?status=0">未审核</a>
            </li>
            <li>
                <a href="/Company/CompanyList?status=1">审核通过</a>
            </li>
            <li>
                <a href="/Company/CompanyList?status=2">审核不通过</a>
            </li>
            <li>
                <a href="/Company/CompanyList?status=3">黑名单</a>
            </li>
        </ul>
    </div>
    <div class="row clearfix">
        <div class="col-md-2 column">
            <span>企业名称</span>
        </div>
        <div class="col-md-3 column">
            <span>企业邮箱</span>
        </div>
        <div class="col-md-4 column">
            <span>工商注册号</span>
        </div>
        <div class="col-md-3 column">
            <span>操作</span>
        </div>
    </div>
    @if (Model.Count() > 0)
    {
        foreach (var com in Model)
        {
            <div class="eee">
                <div class="row clearfix">
                    <div class="col-md-2 column">
                        <a href="/Company/CompanyAudit?companyId=@com.Id">@com.CompanyName</a>
                    </div>
                    <div class="col-md-3 column">
                        @com.Email
                    </div>
                    <div class="col-md-4 column">
                        @com.CompanyNumber
                    </div>
                    <div class="col-md-3 column">
                        @switch (com.Status)
                        {
                            case 0:
                                {
                                    <button onclick="update(@com.Id,1)" class="btn btn-default btn-link" data-toggle="modal" data-target="#myModal">
                                        审核通过
                                    </button>
                                    <button onclick="update(@com.Id,2)" class="btn btn-default btn-link" data-toggle="modal" data-target="#myModal">
                                        审核不通过
                                    </button>
                                };
                                break;
                            case 1:
                                {
                                    <a href="/Position/CompanyPosition?companyId=@com.Id">职位管理</a>
                                    <button onclick="update(@com.Id,3)" class="btn btn-default btn-link" data-toggle="modal" data-target="#myModal">
                                        加入黑名单
                                    </button>
                                };
                                break;
                            case 2:
                                {
                                };
                                break;
                            case 3:
                                {
                                    <button onclick="update(@com.Id,0)" class="btn btn-default btn-link" data-toggle="modal" data-target="#myModal">
                                        移除黑名单
                                    </button>
                                };
                                break;
                        }
                    </div>
                </div>
            </div>
        }
    }
    else
    {
        <br />
        <h4 style="height:300px;text-align:center">无数据。。。</h4>
    }
    <div class="row clearfix">
        <div class="col-md-12 column">
            <div style="text-align: center;">
                <ul class="pagination">
                    @for (int i = (int)ViewData["PageIndex"] - 2 <= 0 ? 1 : (int)ViewData["PageIndex"] - 2; i < (int)ViewData["PageIndex"]; i++)
                    {
                        <li><a href="/Company/CompanyList?status=@((int)ViewData["Status"])&pageIndex=@i">@i</a></li>
                    }
                    @if ((int)ViewData["PageIndex"] > 0)
                    {
                        <li><a href="javascript:;" style="background-color:LightGrey">@((int)ViewData["PageIndex"])</a></li>
                    }
                    @for (int i = (int)ViewData["PageIndex"] + 1; i <= (int)ViewData["PageCount"] && i < (int)ViewData["PageIndex"] + 2; i++)
                    {
                        <li><a href="/Company/CompanyList?status=@((int)ViewData["Status"])&pageIndex=@i">@i</a></li>
                    }
                    <li><a style="border :none;background-color:white">&nbsp;&nbsp;&nbsp;&nbsp;共@((int)ViewData["PageCount"])页</a></li>
                </ul>
            </div>
        </div>
    </div>
</div>

